#ifndef _MB_ADU_H_
#define _MB_ADU_H_

#include "mb_pdu.h"

/**
 * @brief ADU 应用数据单元(Application data unit)
*/

#pragma pack(1)

/**
 *@brief 错误响应ADU
*/
typedef struct __MB_ExceptionADU_HandleTypeDef
{
    uint8_t                          AdditionalAddress;
    MB_ExceptionPDU_HandleTypeDef    Pdu;
    uint16_t                         CRC;
}MB_ExceptionADU_HandleTypeDef;

/**
 *@brief 通用ADU
*/
typedef struct __MB_ADU_HandleTypeDef
{
    uint8_t                       AdditionalAddress;
		MB_PDU_HandleTypeDef          Pdu;
}MB_ADU_HandleTypeDef;

/**
 *@brief 读请求ADU
*/
typedef struct __MB_READ_REQADU_HandleTypeDef
{
    uint8_t                       AdditionalAddress;
    MB_READ_REQPDU_HandleTypeDef  Pdu;
    uint16_t                      CRC;
}MB_READ_REQADU_HandleTypeDef;

/**
 *@brief 读响应ADU
*/
typedef struct __MB_READ_RSPADU_HandleTypeDef
{
    uint8_t                        AdditionalAddress;
    MB_READ_RSPPDU_HandleTypeDef   Pdu;
}MB_READ_RSPADU_HandleTypeDef;

/**
 *@brief 写单个 请求ADU
*/
typedef struct __MB_WRITE_SINGLE_REQADU_HandleTypeDef
{
    uint8_t                               AdditionalAddress;
    MB_WRITE_SINGLE_REQPDU_HandleTypeDef  Pdu;
	  uint16_t                              CRC;
}MB_WRITE_SINGLE_REQADU_HandleTypeDef;

/**
 *@brief 写单个  回复ADU
*/
typedef struct __MB_WRITE_SINGLE_RSPADU_HandleTypeDef
{
    uint8_t                               AdditionalAddress;
    MB_WRITE_SINGLE_RSPPDU_HandleTypeDef  Pdu;
    uint16_t                              CRC;
}MB_WRITE_SINGLE_RSPADU_HandleTypeDef;

/**
 *@brief 写多个 请求ADU
*/
typedef struct __MB_WRITE_MULTIPLE_REQADU_HandleTypeDef
{
    uint8_t                                 AdditionalAddress;
    MB_WRITE_MULTIPLE_REQPDU_HandleTypeDef  Pdu;
}MB_WRITE_MULTIPLE_REQADU_HandleTypeDef;

/**
 *@brief 写多个 回复ADU
*/
typedef struct __MB_WRITE_MULTIPLE_RSPADU_HandleTypeDef
{
    uint8_t                                 AdditionalAddress;
    MB_WRITE_MULTIPLE_RSPPDU_HandleTypeDef  Pdu;
    uint16_t                                CRC;
}MB_WRITE_MULTIPLE_RSPADU_HandleTypeDef;

/**
 *@brief 读写多个 请求ADU
*/
typedef struct __MB_READWRITE_MULTIPLE_REQADU_HandleTypeDef
{
    uint8_t                                     AdditionalAddress;
    MB_READWRITE_MULTIPLE_REQPDU_HandleTypeDef  Pdu;
}MB_READWRITE_MULTIPLE_REQADU_HandleTypeDef;

/**
 *@brief 读写多个 请求ADU
*/
typedef struct __MB_TCP_ADU_HandleTypeDef
{
    uint16_t                                    HandleEvent;
    uint16_t                                    Protocol;
	uint16_t                                    Length;
	uint8_t                                     Pdu[MB_MAX_PDU_DATA_LEN + 4];
}MB_TCP_ADU_HandleTypeDef;

#pragma pack(4)

#endif


